package com.example.dataView.controller;

import com.example.dataView.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author 成大事
 * @since 2022/6/12 20:54
 */
@Api(tags = "图表信息")
@Slf4j
@Validated
@RestController
@RequestMapping("/chartData")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class ChartDataController {

    @ApiOperation(value = "柱状图的数据")
    @PostMapping("/getBarData")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功"),
            @ApiResponse(code = 500,message = "错误"),
    })
    public R<Object> getBarData(){

        String admission = "72.22, 76.25, 81.13, 100.03, 118";
        String apply = "201, 238, 290, 341, 377";
        List<String> admissionList = Arrays.asList(admission.split(", "));
        List<String> applyList = Arrays.asList(apply.split(", "));
        Map<String, List<String>> map = new HashMap<>(2);
        map.put("admissionData",admissionList);
        map.put("applyData",applyList);
        return R.ok(map);
    }


    @ApiOperation(value = "折线图的数据")
    @PostMapping("/getLineData")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功"),
            @ApiResponse(code = 500,message = "错误"),
    })
    public R<Object> getLineData(){

        String typeA = "260, 270, 264, 263, 273";
        String typeB = "250, 260, 254, 253, 263";
        List<String> admissionList = Arrays.asList(typeA.split(","));
        List<String> applyList = Arrays.asList(typeB.split(","));
        Map<String, List<String>> map = new HashMap<>(2);
        map.put("typeAData",admissionList);
        map.put("typeBData",applyList);
        return R.ok(map);
    }

}
